#ifndef THREADPOOLINSTANCE_H
#define THREADPOOLINSTANCE_H

#pragma once

#include <ThreadPool.h>
#include "common/constant.h"

AMCAX_EXCHANGE_NAMESPACE_BEGIN

namespace InterOp {

class ThreadPoolInstance
{
public:
    ThreadPoolInstance(int poolSize);
    ~ThreadPoolInstance();

    template<class F, class... Args>
    auto AddWorker(F&& f, Args&&... args) 
        -> std::future<typename std::result_of<F(Args...)>::type>
    {
        return pool_->enqueue(f,std::forward<Args>(args)...) ;
    }
private:
    std::unique_ptr<ThreadPool> pool_{nullptr};
    int poolSize_ ;
};

}

AMCAX_EXCHANGE_NAMESPACE_END

#endif